home *** CD-ROM | disk | FTP | other *** search
- Path: wisipc.weizmann.ac.il!news
- Newsgroups: comp.lang.c++
- Subject: Heap Memory Management
- Message-ID: <1996Feb4.140550.4699@wisipc.weizmann.ac.il>
- From: Kajdan Dimitry <cerlpvk>
- Date: Sun, 4 Feb 1996 14:05:50 GMT
- Sender: news@wisipc.weizmann.ac.il (News User)
- Organization: Technion - Israel Institute of Technology
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- Mime-Version: 1.0
- X-Mailer: Mozilla 1.1N (X11; I; OSF1 V3.2 alpha)
- X-Url: news://wisipc.weizmann.ac.il/comp.lang.c++
-
- Hi.
- Would someone explain please.
-
- Suppose one got a function that allocates memory on the free store.
-
- char* func(int n)
- {
- char* a=new char[n];
- strcpy(a,"Hello");
- return a;
- }
-
- int main()
- {
-
- char* b=func(10);
-
- return(0);
-
- }
-
- The question is how the memory allocated by new can be freed, since as soon as
- func() terminates the user loses access to it.
- Thanks a lot
-
-